Skip to content

OpenVoice host, phase 1: dictation, translation, answers, hands-free, tools and speaker labels (local) - #3

Open
aliparchekan wants to merge 1 commit into
ThinkFlowLab:mainfrom
aliparchekan:improve-phase1
Open

aliparchekan wants to merge 1 commit into
ThinkFlowLab:mainfrom
aliparchekan:improve-phase1

Conversation

@aliparchekan

@aliparchekan aliparchekan commented Dec 3, 2026 •

Copy link
Copy Markdown

One squashed commit with the whole phase 1 host, including Nemotron live speaker labels and translation without fillers. It replaces #2 (now closed) and includes the speaker-label work that was on the fork.

Updated for the 4 Dec reviews (xiaopyyy and agent-ci-infra-bot): every item is addressed, see "Review fixes" below.
Also new since the review: spoken self-corrections ("at 2 p.m. No, 3 p.m." → "at 3 p.m."), see section 6.

Everything runs on one Mac with local models. Nothing leaves the device.

What it adds

1. Host API (contract 0.6, docs/reference.md)

  • FastAPI service, run with python -m host.sessions.
  • HTTP:
    • POST /v1/dictate (also streaming with ?stream=1), /v1/translate, /v1/respond, /v1/confirm
    • GET /v1/capabilities, /v1/health, and a demo page at /demo
  • WebSocket: /v1/dictate/stream and /v1/listen.
  • Auth: a token is required off loopback. Without one, only the host's own pages are served: another Origin, or a Host other than 127.0.0.1 / localhost / [::1], gets 403 forbidden_origin.
  • Router: each stage goes to a local OpenAI-compatible model server, chosen by environment variables, so models can be swapped without code changes.
    • Speech: Qwen3-ASR-1.7B (accurate) or a 4-bit build (fast).
    • Text: Qwen3-4B-Instruct-2507 (4-bit) for clean-up, translation and answers.

2. Hands-free listening (/v1/listen)

  • Silero VAD (MIT, 1.2 MB, bundled, runs on the CPU) finds where each sentence starts and ends.
  • Live text while speaking, from the fast speech model.
  • In respond mode the session keeps the conversation, so spoken follow-ups work.
  • Detector choice: vad.model is silero (default) or level, the old loudness detector, kept for comparison.
  • Pause length: end_silence_ms sets the pause that ends a sentence. Use 0.8–1.2 s if "uh …" splits sentences.

3. Tools that ask first (MCP)

  • The host is an MCP client: OPENVOICE_MCP names a file in the usual mcpServers format.
  • Confirmation:
    • Read-only tools run directly.
    • Any other tool sends a confirm event and waits. The user answers by clicking (POST /v1/confirm) or by saying yes or no.
    • No answer within 60 s counts as no. Asking can't be turned off ("confirm" is auto or always).
    • A spoken reply with any negation ("okay no, cancel that") is a no; "嗯" is not a yes.
    • Only the tools offered in a turn can run. The built-in web tools need OPENVOICE_TOOLS=1.
  • Example server host/mcp_servers/mac.py: the time, Shortcuts, opening links, and reminders. Reminders accept relative times and clock times.

4. Speaker labels and voice enrolment (opt-in)

  • speakers: true on /v1/listen labels each sentence S1, S2, …, or with a name for enrolled voices.
  • Nemotron-3-Diarization (preferred when OPENVOICE_DIAR_LIB and OPENVOICE_DIAR_MODEL are set; OpenMDW-1.1 license, 107 MB Q8 GGUF, NeMo-Speech.cpp C library):
    • The whole session's audio streams into one diarizer, and each sentence takes the speaker who talked most during it. also lists anyone who talked over them.
    • Keeps people apart over a whole meeting: on a 36-min, 4-person AMI meeting, 18.3% DER vs 45.8% for per-sentence CAM++.
    • No added wait: median speech end to transcript 480 ms vs 525 ms with labels off; 48/48 labels right on a two-voice test. Cost: about 20% of one CPU core while listening. No enrolled names.
  • CAM++ zh/en (Apache-2.0, 28 MB ONNX, via sherpa-onnx), the fallback and the one used for enrolled names.
    • Cost: about 19 ms per sentence, run alongside recognition.
  • The assistant knows who said what: in respond mode each request reaches the model as [Speaker S1] … (or the name), and its own replies are kept as [To S1] …. The host strips that tag from answers, in the stream too.
    • Live, with two voices: S1 likes pizza, S2 wants sushi; "what do I like?" got the right answer for each, and "what should we order for both of us?" got "pizza with olives for you and sushi for S2".
    • Simpler formats failed on the 4B model: with S1: … it wrote lines for S2 and believed them, and without the [To …] tags it answered "I prefer sushi" as if it were S2.
  • Enrolment: POST/GET/DELETE /v1/speakers.
    • Needs the speaker's consent and about 15 s of speech.
    • Only a voiceprint is kept, on the device. The audio is discarded.
  • Results (docs/results/T20.md):
    • Right speaker on 76 of 80 sentences anonymously, and 78 of 80 with enrolled names.
    • 3 of 208 other speakers' turns got the enrolled name, so labels are advisory and never authorise an action.

5. Quality

  • host/eval, on Qwen3-4B 4-bit at temperature 0:

    Result
    Clean-up 21/22 (the flag is a refused edit: the words as spoken were kept)
    Answers 24/24
    Tool choice 10/10
  • Clean-up keeps the spoken language; mixed Chinese-English requests are answered in Chinese.

  • Translation drops spoken fillers (um, uh, ah, er, hmm, 呃, 嗯) before translating, so "Euh, je pense…" becomes "Je pense…". A fixed rule, no added time; "clean_up": false turns it off and raw keeps every word.

6. Spoken self-corrections (polish and translate)

  • "Book me a meeting at 2 p.m. No, 3 p.m." → "Book me a meeting at 3 p.m."; "…七点钟的电影票。哎呀,不对,不对,不对,不对,明天晚上八点钟,对,八点钟。" → "…八点钟的电影票。"
  • How: a correction word anywhere, with or without punctuation (no, sorry, I mean, actually, wait, make it, rather, 不对, 不是, 哦不, 说错…), sends the sentence to the clean-up model, whose prompt keeps only the corrected version. Translate resolves the correction first (clean_up on).
  • Guard: a correction may delete a lot but add almost nothing. It is always refused, and the words as spoken kept, when it drops every negation ("not the 3 p.m. one" → "the 3 p.m. slot") or only drops "sorry" / "actually" while replacing nothing.
  • Results (Qwen3-4B 4-bit): 20/22 short phrasings, 10/11 long English and Chinese sentences, 12/12 look-alikes left as said, 13/13 spoken clips. Still missed: "两点,啊不对,三点开会", "改到下周一,哦不,改到下周二", and "Not 2, 3 p.m." (refused by the negation rule).
  • Cost: ~0.2 s, only for sentences with a correction word. Transcribe mode and raw stay verbatim.

Measured on an M1 Max (warm)

Time
Dictation, accurate ~320 ms
Dictation, fast ~215 ms
Translation +0.2–0.3 s
Follow-up answer starts ~0.1 s
Hands-free, end of sentence to answer ~0.5–0.6 s

Review fixes (4 Dec)

Item Fix
WebSocket / HTTP from other pages Origin and Host check when no token is set (also stops DNS rebinding)
Spoken yes/no negation first, only short affirmatives, 嗯 dropped
Tools not offered refused with "There is no X tool"
"confirm": "never" removed
MCP name clash checked on the cleaned name, with a unique suffix
Third tool round the last round offers no tools, so there is always an answer
stream=true dictation takes a session slot before decoding
Diarizer thread dies stops taking audio; labels fail at once
Delete a name with / DELETE /v1/speakers/{id:path}
Confirm ids full uuid4 hex
READMEs reverted to main (#4 rewrites them)
Other product names removed from docs and comments; prompts/NOTICE and LICENSE-Voxt kept
Licence root LICENSE (Apache-2.0) and NOTICE (ThinkFlowLab; Silero VAD, clean-up prompt, ASCEND, optional CAM++ / Nemotron / NeMo-Speech.cpp)
prompts/NOTICE points at host/eval/README.md, where the ASCEND excerpts are quoted
docs/reference.md contract 0.6, capabilities example from a running host, "since 0.x" headings
host/README.md "What runs today" and where to download both speaker models

Checked live on an M1 Max with real models: a WebSocket from another origin gets forbidden_origin; "Open example.com", then "Okay, no, cancel that" in hands-free respond mode is a no and nothing opens; a read-only tool runs; translation with and without clean_up.

For the frontend

  • A UI served from another origin (a dev server or a webview) needs OPENVOICE_TOKEN set on the host and sent by the client; otherwise it gets 403 forbidden_origin.
  • GET /v1/capabilities lists what the host offers: speeds, listen.vad_models, listen.speakers, tools.mcp.
  • client/demo/index.html is a working client for every feature.
  • docs/integrating.md explains how to add a client.

Known limits

  • First call after idle is slow: about 1–2 s, when the Mac is short on memory.
  • False "done" claims: after an earlier action in the same conversation, the 4B model sometimes says a reminder was set without calling the tool. Starting a new conversation avoids it.
  • Not in this PR: speech output (TTS) and full duplex, which are phase 2.

Test plan

  • python -m pytest -q host: 145 pass. Backends are faked, so CI needs no models.
    • Not covered by CI: the real CAM++ path (speakers.Embedder, load_embedder, needs sherpa-onnx) and the real Nemotron library; both were checked by hand only.
  • Live on an M1 Max with recorded speech:
    • dictation, translation, respond and follow-ups
    • hands-free with live text
    • spoken confirm (no and yes) and reminder creation
    • two enrolled voices labelled correctly
    • two voices in one respond session: who-said-what kept apart
    • Nemotron labels on the same two-voice conversation, transcribe and respond (8 sessions)
    • translate with and without clean_up, English and Chinese speech
    • self-corrections in polish and translate: 13 spoken clips, 33 typed sentences and 12 look-alikes through the host's gate, prompt, model and guard
  • Live microphone session in Safari: hands-free, respond, confirm card, reminder
  • Speaker enrolment with a real microphone
  • Nemotron labels in a real room with real people

The heads before the review fixes and before self-corrections are saved as backup/pre-review-20261204 and backup/pre-selfcorrection-20261204; the former branch heads are saved as backup/* branches on aliparchekan/OpenVoice.

🤖 Generated with Claude Code

@aliparchekan aliparchekan changed the title Host: hands-free listening (Silero VAD, live text), answer-quality pass, MCP tools with confirmation Open Voice host, phase 1: dictation, translation, answers, hands-free, tools and speaker labels (local) Dec 3, 2026
@xiaopyyy xiaopyyy changed the title Open Voice host, phase 1: dictation, translation, answers, hands-free, tools and speaker labels (local) OpenVoice host, phase 1: dictation, translation, answers, hands-free, tools and speaker labels (local) Dec 3, 2026

@agent-ci-infra-bot agent-ci-infra-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two things before this can merge, both from the maintainers' decisions and the current repository state.

1. Licence: the project is Apache-2.0, and the repository still has no LICENSE

The maintainers settled this in the project chat on 2026-12-03: Open Voice is licensed under the Apache License 2.0. The earlier PR that carried this request (#2) is now closed, and main (a5cd9e8) still has no root LICENSE, so please add it here:

  • LICENSE with the full Apache-2.0 text; the copyright line should name ThinkFlowLab, not an individual.
  • Keep host/sessions/prompts/LICENSE-Voxt and NOTICE as they are: section 4 of Apache-2.0 requires the attribution notices to travel with the redistribution of the adapted clean-up prompt. One line in the README pointing at the NOTICE would help readers find it.
  • This PR now bundles two more third-party pieces, so they belong in the same place: Silero VAD (MIT) and CAM++ (Apache-2.0). Both need their licence text next to the bundled model files, and a line in NOTICE saying where they come from and which commit/release was pinned.

2. The branch needs a rebase: GitHub reports this PR as conflicting

main moved to a5cd9e8 when #1 (the product-definition docs) merged, and this PR's base is still 86dea21. Both sides touch README.md / README.zh-CN.md and files under docs/, so the merge is blocked (mergeable_state: dirty) until the branch is rebased onto the current main. Nothing is wrong with the content; it just has to be rebased before it can land.

One smaller note while you are in these files: after #1 merged, the documentation uses OpenVoice while docs/integrating.md and the demo page title still say "Open Voice". Since this PR rewrites those files anyway, aligning the spelling here would leave the repository consistent.

@agent-ci-infra-bot agent-ci-infra-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of 8d0c7ed (57 files, +5238/−30) at contract 0.6

I read the whole tree, ran nothing (no Mac, no models here), and cross-checked code against docs/. The engineering is solid — the confirmation flow, the consent-gated enrolment and the voiceprint store are better thought through than most PRs this size. Three things must be fixed before merge, three should be, and two are minor.

Must fix

M1. host/sessions/prompts/NOTICE cites two files that do not exist.
It says the ASCEND transcript excerpts are documented in eval/manifest.jsonl and docs/results/T3.md. Neither is in the tree: host/eval/ has README.md, cases.jsonl, quality.py; docs/results/ has only T20.md. ASCEND is CC BY-SA 4.0, so the attribution has to point at something a reader can actually open. Either add the manifest (with the licence and the upstream citation) or change the NOTICE to say where the excerpts really are (host/eval/cases.jsonl?).

M2. The NOTICE covers Voxt only.
This PR bundles host/sessions/models/silero_vad_16k_op15.onnx (MIT, and LICENSE-silero-vad is present — good) and gains a CAM++ dependency, yet NOTICE mentions neither. Add a line for each: what it is, upstream, pinned commit/release, licence. host/sessions/models/README.md is the right place to keep the exact provenance for the ONNX files.

M3. docs/reference.md describes a contract the code no longer serves.

  • Line 1: "phase 1, contract 0.4"; GET /v1/capabilities returns contract: "0.6".
  • Lines ~103-116: the capabilities example still shows "contract": "0.1", "modes": ["transcribe", "polish"], "streaming": {"partials": true}. The host actually returns four modes, partials: false, plus a listen object (available, vad, vad_models, speakers) and tools.mcp.
  • Section headings mix 0.3/0.4/0.5/0.6, so a reader cannot tell what is current.
    A client generated from this document would hide features that exist and show one (partials: true) that does not. Pin one version, regenerate the example from the running host, and let the section headings say "since 0.x" only where it matters.

Should fix

S1. Speaker labels are a shipped feature that needs an unpublished download.
speakers.available() is true only when OPENVOICE_SPEAKER_MODEL points at a CAM++ file and sherpa_onnx is importable; host/requirements.txt does not include sherpa-onnx, nothing under host/sessions/models/ is a speaker model, and .gitignore only whitelists the Silero file. So on a fresh clone the feature is off, while the PR description lists it as part of phase 1.
The how-to exists only in docs/results/T20.md (lines ~148-160: install command, release URL, SHA-256, OPENVOICE_SPEAKER_MODEL). Please either

  • bundle the checkpoint the way Silero is bundled (28 MB, needs a .gitignore exception, the Apache-2.0 text and a NOTICE line), or
  • say plainly in host/README.md and docs/reference.md that speaker labels are opt-in, need sherpa-onnx plus a manually downloaded CAM++ checkpoint, and link the T20 instructions. docs/reference.md:194 currently mentions the variable and the SHA-256 check but never tells the reader where to get the file.

S2. host/README.md still describes the empty skeleton.
It lists sessions/jobs/router/devices/workers/storage/cloud as if nothing were implemented. The real entry point is python -m host.sessions, and the host now serves dictation, translation, answers with tools, hands-free listening and speakers. Anyone arriving from the README will not find /v1/listen or the demo page. A short "what runs today" section with the start command would fix it.

S3. Report the untested path as untested.
The 85 test cases (47 functions) are well chosen — test_mcp_action_waits_for_confirmation, test_listen_session_takes_a_spoken_yes, test_speaker_endpoints_off_without_a_model, test_listen_labels_two_voices, the level/silero switch and the pause setting are all covered with faked backends, which is why CI needs no models. But speakers.Embedder, speakers.load_embedder() and everything under spikes/ never execute in CI (no sherpa-onnx), and your own test plan has [ ] Speaker enrolment with a real microphone unchecked. That is fine — just say it in the PR body/README so nobody assumes the real sherpa path is covered.

Minor

N1. POST /v1/confirm ids are short. ask() uses uuid.uuid4().hex[:12] (48 bits) and the endpoint only needs {"id", "approve"} plus the bearer token — which is optional on 127.0.0.1. On a shared machine another local process has a small window (60 s) to approve an action. Use the full uuid4 hex, or bind the pending id to the session that raised it.

N2. Naming. docs/integrating.md and the demo page title still say "Open Voice"; everything merged from #1 says OpenVoice. Cheap to align here since this PR rewrites those files.

What I verified as done well

  • Consent and biometrics: /v1/speakers refuses without consent=true, discards the audio, stores only a vector, writes with mkstemp + os.replace (0600) under ~/.openvoice, and refuses a store made by a different model (409). Exactly the right shape for voiceprints.
  • Model integrity: speakers._load checks the checkpoint SHA-256 before use; the Silero file has a pinned upstream commit and hash in models/README.md.
  • Confirmations: default-ask unless the tool declares readOnlyHint, per-server auto/always/never, 60 s timeout = no, a request that cannot ask declines instead of acting, and declined calls are reported back to the model as "not done".
  • Model context hygiene: tool output truncated to 4000 chars, leading whitespace held back while a tool call may follow, ** stripped, transcript-language pinned for clean-up, and the clean-up gate skips the model for clean sentences.
  • Docs coverage: docs/openapi.yaml does include /v1/confirm and /v1/speakers; docs/integrating.md and T20.md are unusually honest about what was measured and what was not.

Still blocking the merge itself

The branch is still based on 86dea21 while main is a5cd9e8, and GitHub reports the PR as conflicting (README*.md and docs/ changed on both sides). M1–M3 above are content fixes; this one is a rebase.

Reviewed commit: 8d0c7ed
Coverage: PR #3, 57 changed files, whole tree read; nothing executed.

@aliparchekan
aliparchekan force-pushed the improve-phase1 branch 4 times, most recently from ddf0709 to 49270c8 Compare December 4, 2026 19:30
xiaopyyy added a commit to xiaopyyy/OpenVoice that referenced this pull request Dec 4, 2026
- README: centered OpenVoice logo, landscape architecture overview
  (light/dark), release plan v0.1.0 Listen → v1.0.0 Converse, and
  v0.1.0 status based on ThinkFlowLab#3; full Chinese README to match.
- Replace milestones M1–M4 with release versions across the product
  definition, model pipeline and full-duplex diagrams, and AGENTS.md.
- Retire the old layered architecture diagram in favour of
  docs/architecture-overview*.svg (en/zh, light/dark).
- Make doc stubs bilingual, regroup the subsystem map by layer, and add
  knowledge-base, speaker-labels and mcp-tools stubs.

@xiaopyyy xiaopyyy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. Phase 1 is impressive: it is all local, measured and well tested. I'm requesting changes for four issues that break the project's safety rules, plus a few smaller ones. Details are in the inline comments.

Must fix before merge

  1. Any web page can drive the host and approve its own actions: the WebSocket has no Origin check and needs no token on loopback (app.py L602, L649).
  2. A spoken "okay no, cancel that", or a hesitant "嗯", counts as yes (prompts/__init__.py).
  3. Built-in tools run even when they were not offered, so web_search / weather can send queries off the device with OPENVOICE_TOOLS unset (app.py L293).
  4. "confirm": "never" and the trust in readOnlyHint let tools that change things run without asking (mcp_tools.py). AGENTS.md: MCP tools that change anything must ask the user first.

Should fix
5. MCP name clash check uses the raw name but stores the sanitized one, so one server can silently replace another's tool and its confirm flag.
6. The tool loop can run a third round and then return no answer.
7. stream=true dictation decodes before taking a session slot, so OPENVOICE_MAX_SESSIONS doesn't apply.
8. If the diarizer thread dies, feed() keeps queuing audio forever.
9. A speaker enrolled with "/" in the name can't be deleted, so the voiceprint stays on disk.

Docs: please drop the README changes from this PR
#4 rewrites README.md and README.zh-CN.md, adding the release plan (v0.1.0 Listen → v1.0.0 Converse) and a v0.1.0 Status section that already describes this PR. Both PRs touch the same lines, so please revert README.md and README.zh-CN.md here and wait for #4 to merge. After that, rebase and update the Status table if anything changed. #4 also replaces "Phase 1 / 首期" with version numbers across the docs.

Please also remove competitor product names from the docs and code comments. The project's docs describe features rather than comparing them with other products: "Voxt-style" in docs/reference.md, docs/integrating.md and asr-pipeline.md, and "cascaded like Chatterfly" in asr-pipeline.md. The Apache-2.0 attribution in prompts/NOTICE and LICENSE-Voxt must stay, because the licence requires it.

Comment thread host/sessions/app.py
"""Hands-free session: the client streams the microphone; the host finds utterances with a VAD model,
sends live partial text while the user speaks, and processes each utterance in the chosen mode.
In respond mode the session keeps the conversation, so each utterance is a follow-up."""
await ws.accept()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security: cross-site WebSocket hijacking. This socket is accepted without checking Origin, and on 127.0.0.1 auth() needs no token. Any page in the user's browser (evil.example) can open ws://127.0.0.1:8765/v1/listen?mode=respond, stream speech, receive the confirm event, reply {type:"confirm", approve:true} itself, and run run_shortcut / create_reminder. It can also read every transcript.

Suggested fix: reject WebSocket upgrades (and state-changing HTTP requests) whose Origin isn't the host's own origin, or require a per-launch token even on loopback. The same applies to /v1/dictate/stream (L602).

Comment thread host/sessions/app.py

@app.websocket("/v1/dictate/stream")
async def stream(ws: WebSocket):
await ws.accept()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same Origin / loopback-token issue as /v1/listen (see the comment on L649).

def yes_or_no(heard):
"""A spoken answer to "confirm this action?": True, False, or None when it is something else."""
t = re.sub(r"[^\w\s']", "", heard.casefold()).strip()
t = re.sub(r"^(?:um|uh|呃)\s*", "", t)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A spoken "no" can count as yes. (?:yes|yeah|sure|ok|okay)\b.{0,20} matches before any negation is checked, so "okay no, cancel that" returns True. Also, 嗯 is in YES (L190), but it is usually a hesitation filler, not consent.

Suggested fix: check for negations anywhere in the reply first (no / don't / cancel / 不 / 别 / 取消), accept only exact short affirmatives, and drop 嗯 from YES. If in doubt, return None and ask again.

Comment thread host/sessions/app.py
continue
await emit("tool", dict(name=c["name"], arguments=args))
t = time.monotonic()
result = await (mcp_tools.call(c["name"], args) if c["name"] in mcp_tools

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tools run without being offered. Any name that isn't an MCP tool falls through to tools.run(...), even when the built-in tools weren't in specs this turn. With OPENVOICE_TOOLS unset, a web_search call the 4B model writes on its own still sends the user's query to Wikipedia or wttr.in, which breaks the Local First opt-in.

Suggested fix: execute a call only when its name is among the tools offered this turn; otherwise return an "unknown tool" result to the model.

Comment thread host/sessions/app.py Outdated
specs = (tools.SPECS if tools_on else []) + mcp_tools.specs
messages, calls = prompts.respond(raw, opts, actions=bool(mcp_tools.specs), speakers=speakers), []
try:
for _ in range(3): # at most two tool rounds, then a final answer

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says "at most two tool rounds, then a final answer", but the third iteration still sends tools and runs any calls it gets. Then the loop ends and returns (None, calls). A reminder can be created while the client gets an empty answer and a respond_failed warning.

Suggested fix: leave out tools (or force tool_choice: none) on the last iteration.

Comment thread host/sessions/app.py Outdated
raise Fault(409, "enrolment_failed", str(exc)) from None
return dict(model=speakers.MODEL_ID, speakers=[dict(id=n, name=n) for n in names])

@app.delete("/v1/speakers/{speaker_id}")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A voice enrolled as e.g. Ali/Work can't be deleted, because {speaker_id} won't match a slash, even percent-encoded, and DELETE returns 404. The voiceprint is biometric data, so deletion has to work. Reject / at enrolment, use {speaker_id:path}, or switch to opaque ids.

Comment thread host/sessions/diarizer.py
if isinstance(job, bytes):
x = np.frombuffer(job, "<i2").astype(np.float32) / 32768
self.model.check(lib.nemo_speech_diar_stream_push_f32(
self.stream, x.ctypes.data_as(C.POINTER(C.c_float)), len(x), 16000))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this push fails once, _run raises and the thread exits, but feed() keeps adding every 32 ms chunk to self.jobs with no reader. Over a long meeting that grows without bound, and each label() waits about 2 s before failing. Please record that the worker died, and have feed / label drop audio or fail fast (or bound the queue).

Comment thread README.md Outdated

Empty skeleton. Docs layout follows yetone/magpie.
Phase 1 host runs locally on Apple silicon: dictation (accurate / fast speech model), clean-up, translation, and a
Voxt-style respond mode with live streamed answers and follow-ups. See `docs/subsystems/asr-pipeline.md` for latency.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert the README changes in this PR (README.md and README.zh-CN.md). #4 rewrites both READMEs with the release plan and a v0.1.0 Status section that already covers this PR, so these lines will conflict. Once #4 merges, rebase and adjust its Status table if needed.

Also, the docs don't name other products, so "Voxt-style respond mode" would need to become a plain description anyway, e.g. "respond mode: ask or rewrite by voice, with streamed answers and follow-ups".

Comment thread docs/subsystems/asr-pipeline.md Outdated
状态:首期已实现(phase 1 implemented)

首期:ASR 链路。识别、整理、上屏三段;对标 Chatterfly 的级联 ASR + LLM,关注整理段时延。
Recognize → clean up → insert, cascaded like Chatterfly, with the clean-up stage kept off the critical path whenever possible. Measured on an M1 Max (32 GB), warm, through the host:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please describe the pipeline without naming another product: "a cascaded ASR → LLM pipeline". Line 22 can say "adapted from a third-party Apache-2.0 prompt, see prompts/NOTICE". The NOTICE and LICENSE files keep the attribution the licence requires.

Comment thread docs/reference.md Outdated

### Respond mode, streaming and follow-ups (contract 0.4)

- **`mode: "respond"`** on `/v1/dictate`: the spoken request is answered or carried out (Voxt-style Ask/Rewrite).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please drop "(Voxt-style Ask/Rewrite)", for example: "the spoken request is answered, or the selected text is rewritten". The same applies to docs/integrating.md L23 and the "Voxt-style" code comments in app.py and prompts/__init__.py.

@aliparchekan

Copy link
Copy Markdown
Author

Thanks for the thorough review. All items are addressed in e524c6c (still one commit, rebased on main); the table under "Review fixes" in the description maps each one to its fix.

Does it work? Yes. 112 tests pass with faked backends (CI green on the fork). I also checked it live on an M1 Max with the real models:

  • A WebSocket from another origin gets forbidden_origin.
  • "Open example.com", then "Okay, no, cancel that" in hands-free respond mode is taken as a no, and nothing opens.
  • Read-only tools still run without asking.
  • Translation works with and without clean_up.

Two notes:

  • The READMEs are reverted to main, so I left out the README line pointing at the NOTICE. I'll add it after docs: add release plan, logo and new architecture overview #4 merges.
  • LICENSE is the unmodified Apache-2.0 text. "Copyright 2026 ThinkFlowLab" is in the root NOTICE; tell me if you'd rather have it in LICENSE.

xiaopyyy added a commit to xiaopyyy/OpenVoice that referenced this pull request Dec 4, 2026
- README: centered OpenVoice logo, landscape architecture overview
  (light/dark), release plan v0.1.0 Listen → v1.0.0 Converse, and
  v0.1.0 status based on ThinkFlowLab#3; full Chinese README to match.
- Replace milestones M1–M4 with release versions across the product
  definition, model pipeline and full-duplex diagrams, and AGENTS.md.
- Retire the old layered architecture diagram in favour of
  docs/architecture-overview*.svg (en/zh, light/dark).
- Make doc stubs bilingual, regroup the subsystem map by layer, and add
  knowledge-base, speaker-labels and mcp-tools stubs.

Enhance CI by adding some document rules checking
…-free listening, tools and speaker labels

Everything runs on one Mac with local models; nothing leaves the device.

Host (FastAPI, `python -m host.sessions`), API contract 0.6 in docs/reference.md:
- POST /v1/dictate (also ?stream=1), /v1/translate, /v1/respond, /v1/confirm;
  WebSocket /v1/dictate/stream and /v1/listen; /v1/capabilities, /v1/health;
  a demo page at /demo.
- Without a token (loopback only) the host serves only its own pages: a
  foreign Origin, or a Host other than 127.0.0.1/localhost/[::1], gets
  403 forbidden_origin, so no web page can drive it (incl. DNS rebinding).
- Router: each stage (speech, fast speech, clean-up, translation) goes to a
  local OpenAI-compatible model server chosen by environment variables.
  Qwen3-ASR-1.7B (accurate) and a 4-bit build (fast), Qwen3-4B-Instruct-2507.
- Clean-up keeps the spoken language and skips the LLM for clean sentences;
  respond mode answers live, with follow-ups from the conversation.
- Translation drops spoken fillers (um, uh, ah, er, hmm, 呃, 嗯) before
  translating, by a fixed rule with no added time; "clean_up": false keeps
  them. raw always keeps every word.
- Spoken self-corrections are resolved in polish and translate: "Book me a
  meeting at 2 p.m. No, 3 p.m." gives "...at 3 p.m.", "七点...不对,不对...
  八点钟" gives "八点钟". A correction word (no, sorry, I mean, actually, 不对,
  哦不...) sends the sentence to the clean-up model; the guard lets a
  correction delete words but not add any, drop a negation, or only drop
  "sorry"/"actually". 30/33 probe sentences, 12/12 look-alikes kept.
  Transcribe and raw stay verbatim.

Hands-free listening (/v1/listen):
- Silero VAD (MIT, bundled ONNX, CPU) finds each sentence; live partial text
  from the fast speech model while speaking; per-session conversation memory.
- vad.model chooses "silero" or "level" (the old loudness detector, for
  comparison); end_silence_ms sets the pause that ends a sentence.

Tools:
- The host is an MCP client (OPENVOICE_MCP, mcpServers format). Read-only tools
  run directly; any other tool asks first with a confirm event, answered by
  POST /v1/confirm or a spoken yes/no; no answer in 60 s is no. There is no
  way to turn asking off. A spoken answer with any negation ("okay no,
  cancel that") is a no; 嗯 is not a yes.
- Only the tools offered in a turn can run (built-in web tools need
  OPENVOICE_TOOLS=1); the last round offers none, so there is always an answer.
- Example local server host/mcp_servers/mac.py: time, Shortcuts, links,
  reminders (relative and clock times).

Speaker labels (opt-in, speakers: true on /v1/listen):
- Nemotron-3-Diarization (OpenMDW-1.1, Q8 GGUF via NeMo-Speech.cpp), when
  OPENVOICE_DIAR_LIB and OPENVOICE_DIAR_MODEL are set: the whole session
  streams into one diarizer and each sentence takes the speaker who talked
  most; "also" lists anyone who talked over them. Keeps people apart over a
  whole meeting (AMI EN2002a, 36 min: 18.3% DER vs 45.8% per-sentence CAM++).
  No added wait (median speech end to transcript 480 ms vs 525 ms off),
  ~20% of one CPU core.
- CAM++ zh/en (Apache-2.0, 28 MB ONNX via sherpa-onnx), the fallback: labels
  each sentence S1, S2, ... in ~19 ms; enrolled voices get a name.
- POST/GET/DELETE /v1/speakers: consented enrolment from ~15 s of speech,
  stored only as a voiceprint on the device.
- In respond mode the model is told who spoke ([Speaker S1] ...) and whom it
  answered ([To S1] ...), so it keeps people's requests and likes apart.
- Measured and compared candidate models in docs/results/T20.md.

Quality and tests:
- host/eval: clean-up 21/22, respond 24/24, tool choice 10/10 on the 4-bit
  Qwen3-4B. 145 tests with faked backends (CI needs no models).
- CI keeps opentelemetry-api below 1.46: 1.46.0 breaks FastAPI 0.165.1's
  request telemetry (every request fails with a TypeError).

Licence: Apache-2.0 (LICENSE), with NOTICE listing the bundled Silero VAD,
the adapted clean-up prompt, ASCEND excerpts and the optional speaker models.

Squashes the former PRs ThinkFlowLab#2 and #3 and fork PRs #13
and #14 (backups: backup/* branches on aliparchekan/OpenVoice).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
xiaopyyy added a commit to xiaopyyy/OpenVoice that referenced this pull request Dec 5, 2026
- README: centered OpenVoice logo, landscape architecture overview
  (light/dark), release plan v0.1.0 Listen → v1.0.0 Converse, and
  v0.1.0 status based on ThinkFlowLab#3; full Chinese README to match.
- Replace milestones M1–M4 with release versions across the product
  definition, model pipeline and full-duplex diagrams, and AGENTS.md.
- Retire the old layered architecture diagram in favour of
  docs/architecture-overview*.svg (en/zh, light/dark).
- Make doc stubs bilingual, regroup the subsystem map by layer, and add
  knowledge-base, speaker-labels and mcp-tools stubs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants